import Vue from 'vue'
import { checkParams } from './check'

export const ShortMsg = {
    /**
     * @description: 发送信息
     * @param {String} account 消息账户
     * @param {String} templateParams 消息内容
     * @param {Array} userList 接收人
     */
     async sendMsg (account=checkParams('消息账户'), templateParams=checkParams('消息内容'), userList=checkParams('接收人')) {
        let params = {
            account,
            templateParams,
            userList: typeof userList === 'object' ? userList : [userList],
        }
        let res = await Vue.prototype.$request({
            url: "/web/apps/gongqi.os.msgnotify/AliMessage/sendTextMessage",
            method: "post",
            data: params
          })
        if (res.errcode !== 0) {
            throw new Error(res.errmsg)
        }
    }
}